<?
class GoogleSiteMap
{
  var $doc;

  var $ALWAYS  = "always";  //always  (?) 
  var $HOURLY  = "hourly";  //hourly  (?) 
  var $DAILY   = "daily";   //daily   () 
  var $WEEKLY  = "weekly";  //weekly  (?) 
  var $MONTHLY = "monthly"; //monthly (?) 
  var $YEARLY  = "yearly";  //yearly  () 
  var $NEVER   = "never";   //never   () 

  function GoogleSiteMap()
  {
    $this->doc  = '<?xml version="1.0" encoding="UTF-8"?>';
    $this->doc .= '<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">';
  }

  function mask($str)
  {
    $str = str_replace("&","&amp;",$str);
    $str = str_replace("'","&apos;",$str);
    $str = str_replace('"',"&quot;",$str);
    $str = str_replace(">","&gt;",$str);
    $str = str_replace("<","&lt;",$str);
    return $str;
  }

  //add link to XML 
  function AddLink($url,$lastmod="",$changefreq,$priority="") 
  {
    $this->doc .= "<url><loc>".$this->mask($url)."</loc>";
    if($lastmod=="")
    {
       $this->doc .= "<lastmod />";       
    }else
    {
       $this->doc .= "<lastmod>".$lastmod."</lastmod>";
    }
    
    $this->doc .= "<changefreq>".$changefreq."</changefreq>";

    if($priority!="")
    {
       $this->doc .= "<priority>".$priority."</priority>";       
    }
    $this->doc .= "</url>";
  }

  function GetSiteMap()
  {
    $this->doc .= "</urlset>";
    $this->doc = mb_convert_encoding($this->doc, "UTF-8", "ASCII");
    return $this->doc;
  }
}
?>
